Omikron BASIC for Apple Power Mac

3. The Menus of the Editor Contents | 5. The Command Code Set: & to @

 

Chapter 4

Basics

  General Information

Basic Commands
Explanation of Syntax
About the Examples
Further Explanations

  Variable Types

Integer
Float
String
Constants

  Operators

Mathematical Operators
Comparison Operators
Pointers and Address Operators
Priority of the Operators

General Information

BASIC Commands
The Omikron Basic 6 editor accepts a whole series of BASIC commands, which are remainders from previous versions and, among other things, were used there for controlling the old editor and the old interpreter. In Omikron Basic 6, these functions are either carried out by the editor itself (e.g., LIBRARY, DEFINT, RENUM, etc.) or they have lost any practical application purpose because of the new user interface. Others are also typical interpreter commands, which were already always ignored by the compiler because of that. Others in turn used specific properties of ATARI hardware or of the ATARI operating system and are therefore unimportant for the MAC.
To keep compatibility problems with older programs to a minimum (most often it already suffices if the said commands are simply ignored), Omikron Basic 6 is programmed so that the editor also understands invalid commands; however, these are skipped by the compiler.
The insignificant commands are displayed in gray in the chapter 'The Command Set'. These keywords cannot be used by the user for his or her purposes.


Explanation of Syntax
Information in angle brackets <...> is to be replaced by the corresponding expression.
Information in square brackets [...] is, depending on the desired application, an addition than could be left out.
Two square brackets [[...]] set around an expression mean that this expression, depending on the application, can be left out or appear once or several times.
Information in braces {...|...} represents a selection, from which the user is supposed to select one of the two options separated by the bar "|".


About the Examples
Many of the commands are accompanied by short example programs that are displayed in a field with a light yellow background. Most of these programs can be typed in or more easily copied from the online manual and then pasted directly into a program window. However, in many cases some compiler control words must still be placed in order to receive a compileable program (see the Mandelbrot.BAS program in the DEMO folder). In the case of some programs, functions from the Extension Library are also used. In these cases, the Library must be loaded subsequently from within the editor using 'Merge LIBRARY...' and integrated into the program.
The monitor results are shown below in a somewhat darker yellow color, provided it is not a question of graphics, etc. In these cases, behavior of the program is described in a written format.


Further Explanations

<Num. Expression>
A numerical expression is any term supplying a numerical result. In this case, the type is unimportant (integer, simple or double precision). The compiler performs an automatic type conversion during translation. If, however, a command, for example, always expects only one integer type, care should be taken always to pass only integers.
Consequently, the compiled program becomes shorter and faster.


<String Expression>
An expression of the type string.


<File Name>
A file name is a string containing a FileSpecificationRecord and has the following construction:
2 byte VolumeReferenceNumber or 0, if unknown.
4 byte DirectoryIdentificationNumber or 0, if unknown.
1 byte length of the subsequent file name, file path, or partial path.
1-63 bytes file name, file path, or partial path.

A file can be specified on the Macintosh in different ways. If the VolumeReferenceNumber and the DirectoryIdentificationNumber are known, they also should be indicated without fail because absolute non-ambiguity is only guaranteed through them. However, it is also possible to identify a file via a pathname. In this case, the individual folders must be separated with a colon. The actual file name is at the end. (E.g., "MacintoshHD:Omikron Basic:DEMO:Mandelbrot.BAS").

To build a FileSpecificationRecord it is best to use the Get_Fsspec$ function from the Extension Library.
If information about the volume or the directory is missing, the pathname must be complete. A partial pathname is in this case not possible. However, one can set the VolumeReferenceNumber and DirectoryIdentificationNumber to zero and indicate only a file name. The current path is then accepted. To find out the current VolumeReferenceNumber and DirectoryIdentificationNumber, use the procedure Get_Cur_Dir from the Extension Library.
If data about the volume or directory are missing, then the path name has to be indicated in its entirety - if the desired file is not located in the current directory. Otherwise, it is sufficient to indicate partial paths, and write a colon as the first letter of the partial path. In this case you simply set the VolumeReferenceNumber and the DirectoryIdentificationNumber to zero and indicate only a partial path with a preceding colon or a file name without a colon. The program will search for the file in the partial path starting at the current path. In order to find out the current VolumeReferenceNumber and DirectoryIdentificationNumber, you can use the procedure Get_Cur_Dir from the Extension Library.


<Num. Variable>
Numerical variables no matter what type. In individual cases, only simple variables and no fields are maybe permitted.


<Return Variable>
Returns the result value of a command or function. In the case of INPUT USING it is a kind of termination condition.


<Parameters>
The values passed to a function or procedure. If using CALL, a passing as a long integer can be effected if prefixed by "L".


<Bit Number>
Unsigned number between 0 and 31. The weight of the corresponding bit is 2^<bit number>


<Integer Variable>
Integral variables (word=16 bit or long=32 bit); field variables are also permissible.


<Memory Address>
32 bit broad long integer number specifying a specific storage cell.


<Label>
A label or flag determines a specific location within a program. It can consist of any characters allowed for variables. A label can be:

1. A specific line:
If line numbers are used, it is possible to reach a specific line by naming its number. The line number can also be computed, that is, any numerical expression can be used as a label. If, however, the expression consists of only one numerical variable, this variable has to be set within parentheses to prevent being confused with a label.

2. A specific program label:
In every location of the program a label can be identified using "-<identifier>". The identifier may contain all characters authorized for variable names (all alphabetic characters, digits, "_" and the characters 128 to 255). Referring to such a label, it is simply a question of using the identifier; the prefixed minus character is not used. It is also possible to name the label via a string expression. It has to contain the identifier of the label and should not be longer than 8 characters, because the compiler uses only the first 8 characters for an identification evaluation. (This is only valid if the label is accessed via a string expression.)
In general, it is recommended to refrain from using numerical or string expressions for line numbers and/or labels because these have to be first evaluated during runtime and this will slow the execution of the program.

<Drive>
Drive stands for a volume (e.g., fixed disk, CD-ROM, or floppy disk) and can have any name followed by a colon.

<Angle>
Any angle information passed to graphics commands should always be in 1/10 degrees. For example, 900 corresponds to 90 degrees.

<File Number>
An unsigned number between 1 and 16. The number has a fixed connection with the corresponding file (see OPEN). All commands and functions affect the file, which has been allocated to the file number using OPEN.

Variable Types

Omikron Basic offers a whole line of different variable types, which are useful for different purposes. In the interest of a speedy program, only integer variables should be used - if possible - if only integers can be considered as variable values. Because strings are especially complicated, they should be avoided if at all possible.

Variable names can be created almost anyway the user desires. One variable name can also be used several times in the same program as long as different postfixes are used (meaning different value ranges). They are managed completely independent from one another. The postfix takes care of that. The ASCII characters 48-57, 65-90, 95, 97-122, and 128-255 are permitted as variable names. However, the names cannot begin with a number, otherwise BASIC cannot keep them apart from constants.

The characters starting at 128 can be accessed in different ways:

1. With a pre-selection key. First, F1 has to be pressed, and then a normal character is entered. Because of F1, 64 is added to this ASCII code. The same can be done with F2; the only difference is that 128 are added.

2. With the depressed ALT key, it is possible to enter the ASCII code of the character directly via the keypad keys. As soon as the ALT key is released or 3 digits are entered, the desired character appears on the screen.

3. The country-specific special characters can be accessed by pressing a combination of modifier keys and normal keys.

Thus, it is possible now to write, for example, 

Length = Height * SIN(ß)

A suitable font is presupposed.

See also ASCII Codes.

The variable A shall serve as an example. Omikron Basic distinguishes every individual variable from every other one, even if they are all called A. The postfixes for each individual variable already differentiates them. If the variable A%L has already been used, it is still possible to use the independent fields A%L(1) and A%L(1,2) . The difference consists here of the dimension of the fields. However, it is better to avoid such name similarities, otherwise, a program can become unclear very fast.
Incidentally, it is also possible to allocate a standard variable type for each first character permitted to be used as a variable character. Each variable beginning with this letter has then automatically a different standard variable type, unless the postfix of another variable type is explicitly named. (See also Dialog Box: Editor Prefernces.)

The following variable types are possible:

Integer (whole number)
Integer numbers are whole numbers, that is, numbers without decimal places. Their number range is limited to the values indicated below. The advantage of integer numbers is their fast processing and that there are no rounding-off errors.

Long Integer: Computation Range: -2147483648 to +2147483647
  Memory Requirement: 4 bytes (= 4 characters)
  Postfix: %L e.g., A%L, A%L(1)
Word Integer: Computation Range: -32768 to +32767
  Memory Requirement: 2 bytes (= 2 characters)
  Postfix % e.g., A%, A%(1)
Byte Integer: Computation Range: 0 to 255
  Memory Requirement: 1 byte (= 1 character)
  Postfix: %B e.g., A%B(1)
Flag / Boolean: Computation Range: "false" (0) and "true" (-1)
  Memory Requirement: 1 bit (= an eighth of a character)
  Postfix: %F e.g., A%F(1)

Note: The variable types 'Integer Byte' and 'Flag / Boolean' can only be used in fields and not as independent variables.


Float (Floating Point)
Floating point numbers are numbers with decimal places. Their number range is (almost) unlimited since they have an exponent of 10. If the number range of the fraction is not sufficient, each exponent is increased by one, and the fraction is shifted one place to the right. The greater the number, the more inexact it is as well. However, the number of digits always remains identical. For example, a floating point number looks like this:

123.45678 times 10 to the 2nd power
Fraction Exponent

Advantages of these numbers are the decimal places and that the precision adapts to the order. Disadvantages are the rounding-off errors possible with floating point numbers. One third (1/3) is without doubt still something different than 0.333333333333333. Not all real numbers can be exactly represented by a float number. Since the PowerPC has a very powerful floating point computation unit, these types of numbers can have an even greater computation speed than integer numbers.

Single Float: Computation Range: +/-1.4x10^-45 to 3.4x10^+38
  Precision: 7-8 places
  Memory Requirement: 4 byte (= 4 characters)
  Postfix: ! E.G., A!, A!(1)
Double Float: Computation Range: +/-4.9x10^-324 to 1.8x10^+308
  Precision: 15-16 places
  Memory Requirement: 8 byte (= 8 characters)
  Postfix: # e.g., A#, A#(1)



String (Character String)
A string is a character string, that is, a text of up to 2147483648 characters in length. The text can contain any characters from 0 to 255. Strings are managed very effectively by Omikron Basic, which results in a very high processing speed when comparing to other BASIC variants. The length of a string can change during the running of the program (dynamic string management). Thus, strings do not have to be dimensioned in Omikron Basic as they have to in many other BASIC dialects and programming languages.

Strings should only be used if the problem cannot be solved equally well using integers because in spite of the highly optimized management of strings, their use is never as fast as the work with integers.

For example, if only one letter is needed, it is more practical to allocate the corresponding ASCII value to a integer variable (see ASC) and then to work with it instead of using the letter, especially when working with loops with a high execution rate.

String: Memory Requirement: 16 bytes (= 16 characters) plus the length of the string.
  Postfix: A$ e.g., A$(1)


Constants
Constants are numbers, which do not change, that is, they are not variables. But they too have a type, which corresponds to the variable types and is dependent on spelling and the value of the constants:

123 Short Integer
35000 Long Integer
123. Double Float
1.3 Double Float
1E20 Single Float
123! Single Float
123# Double Float
1D20 Double Float
1.23456789 Double Float
"hello" String

A number containing one of the following characters is automatically a floating point number:
. ! # E D
The postfixes ! and # can therefore also stand behind numbers.
The letter E stands for "Exponent Ten" of a single floating number and D for " Exponent Ten"of a double floating number.

Operators
Omikron Basic offers a great number of operators, which are discussed in the following according to the organization of their function groups.

Mathematical Operators

Character: Meaning:
+ Addition
- Subtraction
* Multiplication
/ Division
^ Raise to a power
+= Addition with allocation
-= Subtraction with allocation
*= Multiplication by allocation
/= Division with allocation
\ Integer division: Provides the result of a division rounded off to the nearest whole number
MOD Modul operator: Provides the rest of a whole number division



Comparison Operators

Omikron Basic offers the following comparison operators:
Character:
>
Meaning:
larger as
< smaller as
= equal
>= larger or equal
<= lesser or equal
<> unequal

Pointers and Address Operators

"&" determines the address of a variable, field or function.

"*" accesses an object (de-references it). The pointer variable must follow the operator. The type definition also still has to be indicated here with a postfix - just as in the case of a normal variable. In the special case of a pointer aiming towards functions, using "*"calls the function at which the pointer variable is aiming.


Priority of the Operators
All operators
listet here are explained in detail in Chapter 5 and listed according to priority of the operators. The operators shown more at the top have a higher priority than the ones at the bottom. Operators in the same line have equal priority.

( , ) (parentheses) (highest priority)
& (address operator), * (pointer operator), FN (function)
NOT, +, - (sign)
^
(raise to a power)
SHL, SHR
*, /
\, MOD
+, -
<, <=, >, >=, <>
AND
OR
EQV, IMP, NAND, NOR, XOR
(lowest priority)

Example:

    PRINT -3^2, (-3)^2, 3*1 SHL 2, (3*1) SHL 2

Result:

    -9 9 12 12

Example:

    PRINT -1>=2 OR 1<2, -1>=((2 OR 1)<2)

Result:

    -1 0


3. The Menus of the Editor Contents | 5. The Command Code Set: & to @

Tech-Support | Order | Start | Home: http://www.berkhan.com


© 1997-1999 Berkhan-Software